/*River Warren
 *October 10, 2011
 *
 *Updated Oct 14 2011 12:13AM - John Grange, fix compile bug.
 *Updated Oct 16 2011 9:08PM - River Warren, added inventory get methods
 *Castle.h
 *To be used by the game Dungeons and Princesses
 *Controller class for Room class
 */

#ifndef CASTLE_H_INCLUDED
#define CASTLE_H_INCLUDED

#include <vector>
#include <string.h>
#include "Room.h"
#include <stdio.h> // we will use sprintf instead itoa

using std::vector;

class Castle
{
public:
    Castle();//constructor for new game loads R0
    Castle(string);//constructor for saved game loads room designated by parameter
    virtual ~Castle();
    
    //Room methods******************************
    //move within castle
    //must be contained within try catch block
    void move(int);
    bool unlockDoor(string);//unlock door with proper key Id else throws exception
    string getLinkID(){return rooms[currentRoom].getLinkID();}//return link Id of current room
    void enterRoom(string);//loads new room
    bool hasDoor();//returns true if current room has a door to unlock
    string getKeyCode();//returns key code for opening door
    void saveRooms();//saves all rooms
    Room * getRoom(string roomID);
    
    //base class methods**************************
    string getDesc();//get description of room
    string getObjectType()const{return rooms[currentRoom].getObjectType();}// return the object type
    
    //inventory methods.**********************
    //add something to the inventory by room
    //use this method to preload rooms
    void addByRoom(int roomNum, Base* item){rooms[roomNum].add(item);}
    //add something to the inventory to current room
    //use this method when character 'drops' an item
    void add(Base* item){rooms[currentRoom].add(item);}
    //get a list of what's in the inventory
    //this list is a const pointer
    vector<Listing>const* getManifest(){return rooms[currentRoom].getManifest();}
    int getNumOfItems(){return rooms[currentRoom].getNumOfItems();}
    Key* getKey(int thisKeyID){return rooms[currentRoom].getKey(thisKeyID);} //get a key out of inventory
    
protected:
private:
    int currentRoom;//number of current room of play
    void setCurrentRoom(string);//sets current room from string
    void loadRooms();//loads rooms into array
    vector <Room>rooms;//array of rooms that make up a castle
};

#endif // CASTLE_H_INCLUDED
